/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2021-12-27
 * Time:3:16
 */
import java.io.*;
import java.net.*;
public class Client
{
    public static void main(String args[])
    {
        Socket socketAtClient;
        DataInputStream in = null;
        DataOutputStream out = null;
        try
        {
            socketAtClient = new Socket("localhost", 4333);
            in = new DataInputStream(socketAtClient.getInputStream());
            out = new DataOutputStream(socketAtClient.getOutputStream());
            out.writeInt(1);
            while(true)
            {
                int m2 = 0;
                m2 = in.readInt();
                out.writeInt(m2);
                System.out.println("Client received: " + m2);
                Thread.sleep(500);
            }
        }
        catch(IOException e)
        {
            System.out.println("Unable to connect to the server");
        }
        catch(InterruptedException e){}
    }
}
